<?php

namespace App\Http\Controllers;

use App\Models\Question;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class DraftsController extends Controller
{
    //

    /**
     * DraftsController constructor.
     */
    public function __construct()
    {
        $this->middleware('auth');
    }

    public function index()
    {
//        $drafts = Question::query()->where('user_id', auth()->id())->whereNull('published_at')->get();
        $drafts = Question::drafts(Auth::user());
        return view('drafts.index', [
            'drafts' => $drafts
        ]);
    }
}
